/************************************************************************
*File Name: ls_server.c
*Author: wky
*Created Time: 2023年06月22日 星期四 21时04分46秒
*Describtion: 
************************************************************************/
#include "threadPool.h"

int ls(int netfd, char* real_path){
    
    DIR* pdir = opendir(real_path);
    if(pdir == NULL){
    //NETDESK_LOG_DEBUG("opendir");
    }

    train_t train;
    bzero(&train, sizeof(train));
    if(pdir == NULL){
    send(netfd, &train.length,sizeof(int),MSG_NOSIGNAL);

    //NETDESK_LOG_DEBUG("opendir");
    }


    struct dirent* pdirent;
    while((pdirent = readdir(pdir)) != NULL){
        if(pdirent->d_name[0] == '.'){
            continue;    
        }
        strcat(train.data , pdirent->d_name);
        train.data[strlen(train.data)] = ' ';
    }
    train.length = strlen(train.data);
    send(netfd, &train,sizeof(int)+train.length,MSG_NOSIGNAL);
    closedir(pdir);
    return 0;
}

